# -*- coding: utf-8 -*-
"""
Created on Mon Oct 28 08:33:39 2024

@author: 51testing
"""
from typing import List
from typing import Optional
from sqlalchemy import ForeignKey
from sqlalchemy import String
from sqlalchemy import MetaData, inspect
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.orm import Mapped
from sqlalchemy.orm import mapped_column, MappedColumn
from sqlalchemy.orm import relationship


class Base(DeclarativeBase):
    def to_dict(self) -> str:
        result = {}
        for key in self.__mapper__.c.keys():
            result[key] = getattr(self, key)
        return result
    
    def __clsname__(cls):
        return cls.__class__.__name__
    
    def __repr__(self):
        dict_ = self.to_dict()
        str_ = f"{self.__clsname__()}(" + ', '.join([f"{x}={dict_[x]}" for x in dict_.keys()]) + ")"
        return str_

class Comm(Base):
    __tablename__ = 'commodity'
    c_id: Mapped[str] = mapped_column(primary_key=True)
    c_name: Mapped[str] = mapped_column()
    c_madein: Mapped[str] = mapped_column()
    c_type: Mapped[str] = mapped_column()
    c_inprice: Mapped[int] = mapped_column()
    c_outprice: Mapped[int] = mapped_column()
    c_num: Mapped[int] = mapped_column()
    
class Prob1(Base):
    __tablename__ = "商品表1"
    id: Mapped[str] = mapped_column('商品代号', primary_key=True)
    category: Mapped[str] = mapped_column('分类名')
    price: Mapped[str] = mapped_column('单价')
    amount: Mapped[str] = mapped_column('数量')
    
class Employee(Base):
    __tablename__ = '员工'
    id: Mapped[str] = mapped_column('员工编号', primary_key=True)
    id_number: Mapped[str] = mapped_column('身份证号码')
    name: Mapped[str] = mapped_column('姓名')
    gender: Mapped[str] = mapped_column('性别')
    address: Mapped[str] = mapped_column('家庭住址')
    postcode: Mapped[str] = mapped_column('邮政编码')
    telephone: Mapped[str] = mapped_column('电话号码')
    birth_date: Mapped[str] = mapped_column('出生日期')
    marital_status: Mapped[str] = mapped_column('婚姻状况')
    employee_date: Mapped[str] = mapped_column('雇佣日期')
    s_salary: Mapped[str] = mapped_column('起薪')
    cur_salary: Mapped[str] = mapped_column('目前薪资')
    pay_rise_date: Mapped[str] = mapped_column('加薪日期')
    job_number: Mapped[str] = mapped_column('工作代码')
    department: Mapped[str] = mapped_column('部门')
    direct_supervisor: Mapped[str] = mapped_column('直属主管')
    employee_number: Mapped[str] = mapped_column('员工编号1')
    
class Sc(Base):
    __tablename__ = "选课"
    s_id: Mapped[str] = mapped_column('学生号', primary_key=True)
    c_id: Mapped[str] = mapped_column('课程号', primary_key=True)
    score: Mapped[int] = mapped_column('成绩')
    
class Supplier(Base):
    __tablename__ = '商品供应'
    id: Mapped[str] = mapped_column('供应商编号', primary_key=True)
    name: Mapped[str] = mapped_column('供应商')
    contact: Mapped[str] = mapped_column('联系人')
    contact_job: Mapped[str] = mapped_column('联系人职务')
    address: Mapped[str] = mapped_column('地址')
    city: Mapped[str] = mapped_column('城市')
    district: Mapped[str] = mapped_column('行政区')
    postal: Mapped[str] = mapped_column('邮政编码')
    cnr: Mapped[str] = mapped_column('国家地区')
    phone: Mapped[str] = mapped_column('电话')
    fax: Mapped[str] = mapped_column('传真电话')
    website: Mapped[str] = mapped_column('公司网站')
    
class Student(Base):
    __tablename__ = '学生'
    id: Mapped[str] = mapped_column('学生号', primary_key=True)
    name: Mapped[str] = mapped_column('姓名')
    gender: Mapped[str] = mapped_column('性别')
    major: Mapped[str] = mapped_column('专业')
    
class Game(Base):
    __tablename__ =  'game'
    rq: Mapped[str] = mapped_column(primary_key=True)
    result: Mapped[str] = mapped_column()
    